<template>
  <div style="padding:30px;">
     <header>
      <el-form :inline="true" >
        <el-form-item label="" :class="$style.tinyModify">
          <el-input v-model="telNum" placeholder="请输入手机号码" @keyup.enter.native="handleSearch"></el-input>
        </el-form-item>
        <el-form-item label="" :class="$style.tinyModify" v-show="0">
          <el-input v-model="telNum" placeholder="请输入手机号码" @keyup.enter.native="handleSearch"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSearch">搜索</el-button>
        </el-form-item>
      </el-form>
    </header>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane :label="item.label" :name="item.name" v-for="(item,index) in column" :key="index">
      </el-tab-pane>
    </el-tabs>
    <router-view ></router-view> <!--点击资金记录，所呈现的客户账户信息-->
  </div>
</template>
<script>
export default {
  data () {
    const {power,userGroup} = this.$store.getters.getUserInfo
    let column
    // if(power === 4) {
    //   column = [{
    //       label:"资金记录",
    //       name:"资金记录",
    //     },{
    //       label:"投标记录",
    //       name:"投标记录",
    //     },{
    //       label:"体验金记录",
    //       name:"体验金记录",
    //     },{
    //       label:"奖励记录查询",
    //       name:"奖励记录查询",
    //     }
    //   ]
    //   this.$router.push({ path: `/vip-manage/detail/${this.$route.params.id}/资金记录` })
    // } else {
    //   column = [{
    //       label:"基本信息",
    //       name:"基本信息",
    //     },{
    //       label:"资金记录",
    //       name:"资金记录",
    //     },{
    //       label:"联系记录",
    //       name:"联系记录",
    //     },{
    //       label:"投标记录",
    //       name:"投标记录",
    //     },{
    //       label:"投标汇总",
    //       name:"投标汇总",
    //     },{
    //       label:"体验金记录",
    //       name:"体验金记录",
    //     },{
    //       label:"商品兑换记录",
    //       name:"商品兑换记录",
    //     },
    //     {
    //       label:"奖励选择查询",
    //       name:"奖励选择查询",
    //     },
    //     {
    //       label:"奖励记录查询",
    //       name:"奖励记录查询",
    //     },
    //     {
    //       label:"充值记录",
    //       name:"充值记录",
    //     },
    //     {
    //       label:"积分记录",
    //       name:"积分记录",
    //     },
    //     {
    //       label:"银行流水",
    //       name:"银行流水",
    //     },
    //     {
    //       label:"复投加息",
    //       name:"复投加息",
    //     },
    //     {
    //       label:"红包",
    //       name:"红包",
    //     },
    //     {
    //       label:"现金券",
    //       name:"现金券",
    //     },
    //     {
    //       label:"VIP等级成长值",
    //       name:"VIP等级成长值",
    //     },
    //   ]
    // }
    column = [{
          label:"基本信息",
          name:"基本信息",
        },{
          label:"资金记录",
          name:"资金记录",
        },{
          label:"联系记录",
          name:"联系记录",
        },{
          label:"投标记录",
          name:"投标记录",
        },{
          label:"投标汇总",
          name:"投标汇总",
        },{
          label:"体验金记录",
          name:"体验金记录",
        },{
          label:"商品兑换记录",
          name:"商品兑换记录",
        },
        {
          label:"奖励选择查询",
          name:"奖励选择查询",
        },
        {
          label:"奖励记录查询",
          name:"奖励记录查询",
        },
        {
          label:"充值记录",
          name:"充值记录",
        },
        {
          label:"积分记录",
          name:"积分记录",
        },
        {
          label:"银行流水",
          name:"银行流水",
        },
        {
          label:"复投加息",
          name:"复投加息",
        },
        {
          label:"红包",
          name:"红包",
        },
        {
          label:"现金券",
          name:"现金券",
        },
        {
          label:"加息券",
          name:"加息券",
        },
        {
          label:"VIP等级成长值",
          name:"VIP等级成长值",
        },
        {
          label:"会员日志",
          name:"会员日志",
        },
      ]
    for(let i = 0; i < column.length; i++ ){
      if(power === 2 && userGroup === '答疑组' && (column[i].label === '充值记录')){
        column.splice(i,1)
        i--
      }
      if(power > 1 && (column[i].label === '会员日志')){
        column.splice(i,1)
        i--
      }
      // if(userGroup === '业务组' && (column[i].label === '资金记录')){
      //   column.splice(i,1)
      //   i--
      // }
    }
    return {
      telNum:'',
      id:this.$route.params.id,
      activeName: this.$route.name,
      column,
    }
  },
  methods: {
    handleClick(tab, event) {
      let a= tab.label
      switch(a){
        case '基本信息' :
          a = 'jbxx'
          break;
        case '资金记录' :
          a = 'zjjl'
          break;
        case '联系记录' :
          a = 'lxjl'
          break;
        case '投标记录' :
          a = 'tbjl'
          break;
        case '投标汇总' :
          a = 'tbhz'
          break;
        case '体验金记录' :
          a = 'tyjjl'
          break;
        case '商品兑换记录' :
          a = 'spdhjl'
          break;
        case '奖励选择查询' :
          a = 'jlxzcx'
          break;
        case '奖励记录查询' :
          a = 'jljlcx'
          break;
        case '积分记录' :
          a = 'jfjl'
          break;
        case '银行流水' :
          a = 'yhls'
          break;
        case '复投加息' :
          a = 'ftjx'
          break;
        case '红包' :
          a = 'hb'
          break;
        case '现金券' :
          a = 'xjq'
          break;
        case '加息券' :
          a = 'jxq'
          break;
        case 'VIP等级成长值' :
          a = 'vip'
          break;
        case '充值记录' :
          a = 'czjl'
          break;
        case '会员日志' :
          a = 'viprz'
          break;
      }
      this.$router.push({ path:`/vip-manage/detail/${this.id}/${a}`})
    },
    handleSearch(){
      const telNum = this.telNum
      this.getId(telNum)
    },
    async getId(phone){
      const page = 1
      const pageSize = 10
      try{
        const {data} = await this.$get(this,{api:'manage/exactFind.do',data: {
              groupId: this.$store.getters.getUserInfo.userGroupId,
              id: '',
              cU_ser: '',
              cMtel: phone,
              cZjhm: '',
              pageSize,
              page,
            }
          })
        
        if (data.state === 0) {
          if(data.content.data.length > 0){
            const id = data.content.data[0].id
            this.activeName = '基本信息'
            this.$router.replace({ path:`/vip-manage/detail/${id}/jbxx`})
            return
          }
          this.$toast({
            message:'暂无数据'
          })
        } else {
          this.$toast({
            message: data.message
          })
        }
      }catch(e){
        this.$warn('manage/exactFind.do:' + e)
      }
    }
  },
  watch:{
    $route(val){
      // console.log(val.params.id)
      this.id = val.params.id
    }
  },
  mounted () {
  }
}
</script>

<style lang="scss" module>
.tinyModify{
  margin-right:18px !important;
  margin-bottom:16px !important;
}
</style>

<style>
  .el-tabs__item {
    color: #000;
  }
  .el-tabs__item.is-active {
    font-weight: bold;
  }
</style>


